<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>双向绑定</title>
</head>
<body>
<div id="app">
    <form>
        账号：<input v-model="username"><br>
        密码：<input v-model="password"><br>
        昵称：<input v-model="nickname"><br>
        地址：<input v-model="address"><br>

        <input type="button" value="获取表单的数据" @click="getData"><br>
        <input type="button" value="设置表单的数据" @click="setData">
    </form>
</div>

<script src="js/vue.js"></script>
<script>
    var vue = new Vue({
        el: "#app",
        data: {
            username:"",
            password:"",
            nickname:"",
            address:""
        },
        methods:{
            getData(){
                console.log(this.username);
                console.log(this.password);
                console.log(this.nickname);
                console.log(this.address);
            },
            setData(){
                this.username = "admin";
                this.password = "123456";
                this.nickname = "管理员";
                this.address = "深圳";
            }
        }
    });
</script>
</body>
</html>